#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<limits.h>
#include<string.h>
#include<assert.h>
#include<math.h>
#include<time.h>
#include<rav.h>

uint64_t low_freq[LOW_FREQ_SIZE];

int 
get_freq_code(int idx)
{
   assert((idx>>LOW_FREQ_SHIFT)<LOW_FREQ_SIZE);
   return (low_freq[idx>>LOW_FREQ_SHIFT]&(1LL<<(idx&LOW_FREQ_MASK)))!=0;
}

void 
set_freq_code(int idx, int v)
{
   assert((idx>>LOW_FREQ_SHIFT)<LOW_FREQ_SIZE);
   if (v)
      low_freq[idx>>LOW_FREQ_SHIFT] |= (1LL<<(idx&LOW_FREQ_MASK));
   else
      low_freq[idx>>LOW_FREQ_SHIFT] &= ~(1LL<<(idx&LOW_FREQ_MASK));
}

int main()
{
   set_freq_code(0, FREQ_LOW);
   set_freq_code(10, FREQ_LOW);
   set_freq_code(64, FREQ_LOW);
   set_freq_code(127, FREQ_LOW);
   printf("%016llx\n", low_freq[0]);
   printf("%016llx\n", low_freq[1]);
   set_freq_code(1392, FREQ_LOW);
   set_freq_code(1241, FREQ_OK);
   set_freq_code(800, FREQ_OK);
   printf("%d\n", get_freq_code(0));
   printf("%d\n", get_freq_code(1392));
   printf("%d\n", get_freq_code(1241));
   printf("%d\n", get_freq_code(800));
   return 0;
}
